package com.zzz.robot201.service.client;

import android.os.Build;

import java.util.Date;

import androidx.annotation.RequiresApi;

public class LongToDword2 {
    public static long dwordBytesToLong(byte[] data) {
        return (data[3] << 8 * 3) + (data[2] << 8 * 2) + (data[1] << 8)
                + data[0];
    }

    public static byte[] longToDword(long value) {
        byte[] data = new byte[4];

        for (int i = 0; i < data.length; i++) {
            data[i] = (byte) (value >> (8 * i));
        }
        return data;
    }

    @RequiresApi(api = Build.VERSION_CODES.O)
    public static void main(String[] args) {
        long l = new Date().getTime();
        System.out.println(l);
        System.out.println(dwordBytesToLong(longToDword(l)));


        long l2 = Integer.toUnsignedLong(-1000000000);
        l2 = Long.parseUnsignedLong(l+"");
        System.out.println(l2);
    }
}
